home *** CD-ROM | disk | FTP | other *** search
- #include <ConsLaw.h>
- #include <createHCLSchemes.h>
- #include <DrawFD.h>
-
- real start1 (const Ptv(real)& x, real t) { return 0.0; }
- real linearFlux (real u) { return u; }
-
- void ConsLaw:: solveProblem ()
- {
- setIC (); // set initial conditions
- timeLoop (); // perform time stepping
- }
-
- void ConsLaw:: setIC () // initial conditions
- { u_prev() = start1; }
-
- void ConsLaw:: scan (Is is)
- {
- f = linearFlux;
-
- grid.rebind (new GridLattice(1)); grid->scan (is);
- u.rebind (new FieldFD (grid(), "u"));
- u_prev.rebind (new FieldFD (grid(), "u_prev"));
- const real uL = 1; u->valueIndex(0) = u_prev->valueIndex(0) = uL;
- tip.scan (is);
- file.open (CaseName);
- time_points_for_plot.scan (is);
- is >> scheme_tp; // scheme type:
- scheme.rebind (createHCLSchemes (scheme_tp, *this));
-
- // write input data for a check:
- u->grid().print(s_o); tip.print(s_o);
- s_o << "time points for plot: "; time_points_for_plot.print (s_o);
- }
-
- void ConsLaw:: timeLoop ()
- {
- tip.initTimeLoop();
- while (!tip.finished()) {
- tip.increaseTime();
- scheme->update ();
- saveResults ();
- updateDataStructures ();
- }
- }
-
- void ConsLaw:: saveResults ()
- {
- // dump plot data values on file casename.pl if any given point of
- // time for plotting is within 0.5*dt from the present time value:
-
- if (time_points_for_plot.within (tip.getTime(), 0.4999*tip.Delta()))
- DrawFD::makeCurvPlot (u(),file,"u(x) for t fixed","u",
- oform("t=%g",tip.getTime()));
- }
-
- void ConsLaw:: updateDataStructures () { u_prev() = u(); }
-